/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package meshindexer.idretriever;

import gov.nih.nlm.ncbi.www.soap.eutils.EUtilsServiceStub;
import java.util.Vector;

/**
 *
 * @author Dallaz
 */
public class IdRetriever {

    protected String term;

    public IdRetriever(String term) {
        this.term = term;
    }

    public Vector<String> getIds() throws Exception {
        Vector<String> ids = new Vector<String>();
        EUtilsServiceStub service = new EUtilsServiceStub();
        EUtilsServiceStub.ESearchRequest req = new EUtilsServiceStub.ESearchRequest();
        req.setDb("pubmed");
        req.setTerm(term+"[mh]");
        //req.setField("mesh");
        req.setSort("last+author");
        EUtilsServiceStub.ESearchResult res = service.run_eSearch(req);
        int N = res.getIdList().getId().length;
        for (int i = 0; i < N; i++) {
            ids.add(res.getIdList().getId()[i]);
        }
        return ids;
    }
}
